/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.feedback.service.processor.edit;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import info.peigen.hotpot.component.feedback.domain.Feedback;
import info.peigen.hotpot.component.feedback.service.order.FeedbackEditOrder;
import info.peigen.hotpot.component.feedback.service.processor.AbstractFeedbackServiceProcessor;
import org.noear.solon.annotation.Component;

/**
 * <b>(FeedbackEditProcessor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/1/7
 */
@Component
public class FeedbackEditProcessor extends AbstractFeedbackServiceProcessor implements Processor {
    @Override
    public Integer level() {
        return 20;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {
        FeedbackEditOrder editOrder = (FeedbackEditOrder) serviceContext.getOrder();
        Feedback          feedback  = (Feedback) serviceContext.getDomain();

        if (ObjUtil.isNotNull(editOrder.getContext())) {
            feedback.setContext(editOrder.getContext());
        }

        if (CollUtil.isNotEmpty(editOrder.getImages())) {
            feedback.getImages().addAll(editOrder.getImages());
        }
    }
}